﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Hope.Gallery.Models;
using Hope.Gallery.Core;
using System.Web.Mvc;

namespace Hope.Gallery.ViewModels
{
    public class IndexModel : BaseViewModel
    {
        public Album CurrentAlbum { get; set; }
        public List<AlbumDetail> CurrentAlbumDetails { get; set; }

        public IndexModel()
        {
        
        }


        /// <summary>
        /// Get album by Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public void GetAlbumById(int id)
        {
            Business.Album album = bl.GetAlbumById(id);
            
            if (album != null)
            {
                CurrentAlbum = new Album 
                {
                    Id = album.Id, 
                    Description = album.Description,
                    Title = album.Title
                };

                CurrentAlbumDetails =
                    album.AlbumDetails
                    .Select(ad => new AlbumDetail 
                    {

                        PicturePath =  DirectoryHelper.GetRelativePhotoPath(ad.AlbumId.ToString(), ad.Filename) + "?width=1024&heigth=800",
                        ThumbPath = DirectoryHelper.GetRelativeThumbPath(ad.AlbumId.ToString(), ad.Filename), 
                        PictureName = ad.Filename

                    }).ToList();
            }
        }

    }
}